package com.example.android_common.view.iosdialog;

import com.example.android_common.view.iosdialog.ActionSheetDialog.OnSheetItemClickListener;
import com.example.android_common.view.iosdialog.ActionSheetDialog.SheetItemColor;

import android.content.Context;

/**
 * 简化IOSDialog创建
 * @author hubin
 */
public class SheetDialogUtil {
	
	/**
	 * 显示ActionSheetDialog
	 * @param context
	 * @param names
	 * @param listener
	 */
	public static void showActionSheetDialog(Context context,String[] names,OnSheetItemClickListener listener){
		ActionSheetDialog dialog = new ActionSheetDialog(context);
		dialog
		.builder()
		.setCancelable(true)
		.setCanceledOnTouchOutside(true);
		
		addItem(dialog, names, listener);
		dialog.show();
	}
	
	/**
	 * 给ActionSheetDialog添加Item
	 * @param dialog
	 * @param names
	 * @param listener
	 */
	private static void addItem(ActionSheetDialog dialog,String[] names,OnSheetItemClickListener listener){
		for(int i = 0;i<names.length;i++){
			dialog.addSheetItem(names[i], SheetItemColor.Blue, listener);
		}
	}
	
}
